<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:mybatis="http://mybatis.org/schema/mybatis-spring"

	xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
		http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd">

	<tx:annotation-driven transaction-manager="transactionManager" />

	<tx:jta-transaction-manager />
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="uy.edu.cei.taller2.dataaccess.mappers" />
	</bean>

	<bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="mapperLocations" value="classpath*:mappers/**/*.xml" />
		<property name="transactionFactory">
	<!-- 		<bean
				class="org.apache.ibatis.transaction.managed.ManagedTransactionFactory" /> -->
				<bean
				class="org.mybatis.spring.transaction.SpringManagedTransactionFactory" />
		</property>
	</bean>

	<jdbc:embedded-database id="dataSource" type="H2">
		<jdbc:script location="classpath:sql/dev-schema.sql" />
		<jdbc:script location="classpath:sql/dev-data.sql" />
	</jdbc:embedded-database>
	
	<!-- Esto es solo para postgresql y mysql
	<jdbc:initialize-database>
      <jdbc:script location="classpath:sql/dev-schema.sql" />
      <jdbc:script location="classpath:sql/dev-data.sql" />
    </jdbc:initialize-database>
 	-->
 	
	<bean id="dataSource-postgresql"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="org.postgresql.Driver" />
		<property name="url"
			value="jdbc:postgresql://localhost:5432/mi-base-de-datos" />
		<property name="username" value="username" />
		<property name="password" value="password" />
	</bean>

	<bean id="dataSource-mysql"
		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver" />
		<property name="url"
			value="jdbc:postgresql://localhost:3306/mi-base-de-datos" />
		<property name="username" value="username" />
		<property name="password" value="password" />
	</bean>
</beans>
